﻿using Artech.Core.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Caching;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace Artech.Core.Caching.Configuration
{
    /// <summary>
    /// The general cache store based <see cref="ConfigurationElement"/>.
    /// </summary>
    public class CacheStoreData : ConfigurationElement
    {
        private const string PropertyName4Enabled = "enabled";
        private const string PropertyName4CacheManager="cacheManager";
        private const string PropertyName4ExpirationMode = "expirationMode";
        private const string PropertyName4Priority = "priority";
        private const string PropertyName4ExpiredTime = "expiredTime";
        private const string PropetyName4DepedencyFileName = "dependencyFileName";

        [ConfigurationProperty(PropertyName4Enabled, IsRequired = false, DefaultValue = false)]
        public bool Enabled
        {
            get { return (bool)base[PropertyName4Enabled]; }
            set { base[PropertyName4Enabled] = value; }
        }

        /// <summary>
        /// Gets or sets the cache manager name.
        /// </summary>
        /// <value>
        /// The cache manager name.
        /// </value>
        [ConfigurationProperty(PropertyName4CacheManager,IsRequired = false, DefaultValue = "")]
        public string CacheManager
        {
            get { return (string)base[PropertyName4CacheManager]; }
            set { base[PropertyName4CacheManager] = value; }
        }

        /// <summary>
        /// Gets or sets the expiration mode.
        /// </summary>
        /// <value>
        /// The expiration mode.
        /// </value>
        [ConfigurationProperty(PropertyName4ExpirationMode, IsRequired = false, DefaultValue = CacheExpirationMode.Never)]
        public CacheExpirationMode ExpirationMode
        {
            get { return (CacheExpirationMode)base[PropertyName4ExpirationMode]; }
            set { base[PropertyName4ExpirationMode] = value; }
        }

        /// <summary>
        /// Gets or sets the priority.
        /// </summary>
        /// <value>
        /// The priority.
        /// </value>
        [ConfigurationProperty(PropertyName4Priority, IsRequired = false, DefaultValue = CacheItemPriority.Normal)]
        public CacheItemPriority Priority
        {
            get { return (CacheItemPriority)base[PropertyName4Priority]; }
            set { base[PropertyName4Priority] = value; }
        }

        /// <summary>
        /// Gets or sets the expired time.
        /// </summary>
        /// <value>
        /// The expired time.
        /// </value>
        [ConfigurationProperty(PropertyName4ExpiredTime, IsRequired = false, DefaultValue = "")]
        public string ExpiredTime
        {
            get { return (string)base[PropertyName4ExpiredTime]; }
            set { base[PropertyName4ExpiredTime] = value; }
        }

        /// <summary>
        /// Gets or sets the name of the depedency file.
        /// </summary>
        /// <value>
        /// The name of the depedency file.
        /// </value>
        [ConfigurationProperty(PropetyName4DepedencyFileName, IsRequired = false, DefaultValue = "")]
        public string DepedencyFileName
        {
            get { return (string)base[PropetyName4DepedencyFileName]; }
            set { base[PropetyName4DepedencyFileName] = value; }
        }
    }
}